package com.es.www.original.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import com.es.www.original.staticProxy.RealImage;

/**
 * @Created by michangtao
 * @Date 2022/4/28 17:39
 * @Description
 */
public class DynamicProxyImageHandler implements InvocationHandler {

    private RealImage realImage;

    private String name;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if(realImage == null){
            realImage = new RealImage(name);
        }
        return realImage.display();
    }
}
